#include "ScoreScene.h"
#include "HelloWorldScene.h"

USING_NS_CC;


using namespace cocos2d;
using namespace cocos2d::extension;
using namespace gui;

CCScene* ScoreScene::scene()
{
	// 'scene' is an autorelease object
	CCScene *scene = CCScene::create();

	// 'layer' is an autorelease object
	ScoreScene *layer = ScoreScene::create();

	//// add layer as a child to scene
	scene->addChild(layer);

	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
bool ScoreScene::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}

	UILayer *player = UILayer::create();
	player->addWidget(GUIReader::shareReader()->widgetFromJsonFile("line_4.json"));
	Widget *button;
	button = player->getWidgetByName("m_fanhui");
	if (button)
	{
		button->addTouchEventListener(player,toucheventselector(ScoreScene::kaishi));
	}

	this->addChild(player);

	return true;
}

void ScoreScene::kaishi(CCObject* pSender,TouchEventType type)
{
	CCTransitionScene * reScene = NULL;
	CCScene * s = HelloWorld::scene();
	float t = 1.2f;
	//reScene = CCTransitionProgressVertical::create(t, s);
	reScene = CCTransitionJumpZoom ::create(t , s);
	//reScene = CCTransitionProgressInOut::create(t, s);
	CCDirector::sharedDirector()->replaceScene(reScene);;
}


void ScoreScene::menuCloseCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	exit(0);
#endif
#endif
}
